home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / KDFrameProfileSection.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-30  |  7.4 KB  |  233 lines

  1. /* -*- Mode: C++ -*-
  2.    KDChart - a multi-platform charting engine
  3.    */
  4.  
  5. /****************************************************************************
  6.  ** Copyright (C) 2001-2003 Klar├ñlvdalens Datakonsult AB.  All rights reserved.
  7.  **
  8.  ** This file is part of the KDChart library.
  9.  **
  10.  ** This file may be distributed and/or modified under the terms of the
  11.  ** GNU General Public License version 2 as published by the Free Software
  12.  ** Foundation and appearing in the file LICENSE.GPL included in the
  13.  ** packaging of this file.
  14.  **
  15.  ** Licensees holding valid commercial KDChart licenses may use this file in
  16.  ** accordance with the KDChart Commercial License Agreement provided with
  17.  ** the Software.
  18.  **
  19.  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20.  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21.  **
  22.  ** See http://www.klaralvdalens-datakonsult.se/?page=products for
  23.  **   information about KDChart Commercial License Agreements.
  24.  **
  25.  ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
  26.  ** licensing are not clear to you.
  27.  **
  28.  **********************************************************************/
  29. #ifndef __KDFRAMEPROFILESECTION__
  30. #define __KDFRAMEPROFILESECTION__
  31.  
  32. #include <qregion.h>
  33. #include <qpen.h>
  34. #include <qdom.h>
  35. #include "KDChartGlobal.h"
  36.  
  37.  
  38. /**
  39.   Settings for one profile section of one side of the frame.
  40.   */
  41. class KDCHART_EXPORT KDFrameProfileSection
  42. {
  43. public:
  44.     /**
  45.     Profile Direction Mode: specifying whether a part of a profile looks embossed or
  46.     engraved in comparison to the next outer part (or to the surrounding area, resp.).
  47.  
  48.     \li \c DirPlain the part of the profile is neither embossed nor engraved.
  49.     \li \c DirRaising the part of the profile lookes embossed from the outer part.
  50.     \li \c DirSinking the part of the profile lookes engraved into the outer part.
  51.  
  52.     \Note Since a frame border may consist of several parts you must specify the
  53.     direction mode for each of these parts. This is quite different from the
  54.     QFrame::Shadow / QFrame::Shape schema where you would select a predefined
  55.     profile. KDFrame lets you specify both the number of sections used
  56.     to compose frame border's profile and the look of each individual
  57.     section by calling \c addProfileSection() multiple times.
  58.  
  59.     Some commonly used profiles are allready pre-defined for your convenience,
  60.     \c setSimpleProfile is used to select one of them, see \c setProfile
  61.     for an example how to do this.
  62.  
  63.     \sa addProfileSection, setProfile, setSimpleProfile, SimpleProfile
  64.     */
  65.     enum Direction { DirPlain, DirRaising, DirSinking };
  66.  
  67.     /**
  68.     Converts the specified direction enum to a string representation.
  69.  
  70.     \param dir the direction enum to convert
  71.     \return the string representation of the direction enum
  72.     */
  73.     static QString directionToString( Direction dir ) {
  74.         switch( dir ) {
  75.             case DirPlain:
  76.                 return "Plain";
  77.             case DirRaising:
  78.                 return "Raising";
  79.             case DirSinking:
  80.                 return "Sinking";
  81.             default: // should not happen
  82.                 return "Plain";
  83.         }
  84.     }
  85.  
  86.  
  87.     /**
  88.     Converts the specified string to a direction enum value.
  89.  
  90.     \param string the string to convert
  91.     \return the direction enum value
  92.     */
  93.     static Direction stringToDirection( const QString& string ) {
  94.         if( string == "Plain" )
  95.             return DirPlain;
  96.         else if( string == "Raising" )
  97.             return DirRaising;
  98.         else if( string == "Sinking" )
  99.             return DirSinking;
  100.         else // default, should not happen
  101.             return DirPlain;
  102.     }
  103.  
  104.  
  105.  
  106.     /**
  107.     Profile Curvature Mode: specifying the shape of a frame profile section.
  108.     (curvature setting will be ignored for \c DirPlain profiles)
  109.  
  110.     \li \c CvtFlat looking like a evenly sloping surface.
  111.     \li \c CvtConvex looking like quarter of a torus.
  112.     \li \c CvtConcave looking like half of a groove.
  113.     */
  114.     enum Curvature { CvtPlain, CvtConvex, CvtConcave };
  115.  
  116.     /**
  117.     Converts the specified curvature enum to a string representation.
  118.  
  119.     \param curv the curvature enum to convert
  120.     \return the string representation of the curvature enum
  121.     */
  122.     static QString curvatureToString( Curvature curv ) {
  123.         switch( curv ) {
  124.             case CvtPlain:
  125.                 return "Plain";
  126.             case CvtConvex:
  127.                 return "Convex";
  128.             case CvtConcave:
  129.                 return "Concave";
  130.             default: // should not happen
  131.                 return "Plain";
  132.         }
  133.     }
  134.  
  135.  
  136.     /**
  137.     Converts the specified string to a curvature enum value.
  138.  
  139.     \param string the string to convert
  140.     \return the curvature enum value
  141.     */
  142.     static Curvature stringToCurvature( const QString& string ) {
  143.         if( string == "Plain" )
  144.             return CvtPlain;
  145.         else if( string == "Convex" )
  146.             return CvtConvex;
  147.         else if( string == "Concave" )
  148.             return CvtConcave;
  149.         else // default, should not happen
  150.             return CvtPlain;
  151.     }
  152.  
  153.  
  154.     /**
  155.     Ctor of KDFrameProfileSection.
  156.  
  157.     \Note Instead of instantiating KDFrameProfileSection yourself
  158.     you would normally rather call \c KDFrame::addProfileSection()
  159.     */
  160.     KDFrameProfileSection( Direction direction,
  161.                            Curvature curvature,
  162.                            int       width,
  163.                            QPen      pen )
  164.         : _direction( direction ),
  165.           _curvature( curvature ),
  166.           _width( width ),
  167.           _pen( pen ) {}
  168.  
  169.     /**
  170.     Default ctor of FrameProfileSection.
  171.  
  172.     \Note Instead of instantiating KDFrameProfileSection yourself,
  173.     you would normally rather call \c KDFrame::addProfileSection()
  174.     */
  175.     KDFrameProfileSection() {
  176.         _direction = DirPlain;
  177.         _curvature = CvtPlain;
  178.         _width = 1;
  179.         _pen = QPen( Qt::SolidLine );
  180.     }
  181.  
  182.     /**
  183.     Destructor. Only defined to have it virtual.
  184.     */
  185.     virtual ~KDFrameProfileSection();
  186.  
  187.     /**
  188.     Creates a DOM element node that represents a frame profile
  189.     section for use in a DOM document.
  190.  
  191.     \param document the DOM document to which the node will belong
  192.     \param parent the parent node to which the new node will be appended
  193.     \param elementName the name of the new node
  194.     \param section the section to be represented
  195.     */
  196.     static void createFrameProfileSectionNode( QDomDocument& document,
  197.             QDomNode& parent,
  198.             const QString& elementName,
  199.             const KDFrameProfileSection* section );
  200.  
  201.     /**
  202.     Reads data from a DOM element node that represents a frame
  203.     profile section and fills a KDFrameProfileSection object with
  204.     the data.
  205.  
  206.     \param element the DOM element to read from
  207.     \param section a pointer to the frame profile section object to
  208.     read the data into
  209.     */
  210.     static bool readFrameProfileSectionNode( const QDomElement& element,
  211.             KDFrameProfileSection* section );
  212.  
  213.     Direction direction() const { return _direction; }
  214.     Curvature curvature() const { return _curvature; }
  215.     int       width()     const { return _width;     }
  216.     QPen      pen()       const { return _pen;       }
  217.  
  218. private:
  219.     Direction _direction;
  220.     Curvature _curvature;
  221.     int       _width;
  222.     QPen      _pen;
  223. };
  224.  
  225. /**
  226.   Settings for all the profile sections of one side the frame.
  227.  
  228.   \sa setProfile, profile
  229.   */
  230. typedef QPtrList < KDFrameProfileSection > KDFrameProfile;
  231.  
  232. #endif
  233.